package com.itheima.reggie.dao;

import com.itheima.reggie.entity.Employee;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface EmployeeMapper {
    @Select("select * from employee where username = #{userName}")
    Employee getByName(String userName);

    @Select("<script>select * from employee <where> <if test=\"name!=null and name!=''\"> username like concat(\"%\",#{name},\"%\")</if></where> </script>")
    List<Employee> getlistByName(String name);

    @Insert("insert into employee values (#{id},#{name},#{username},#{password},#{phone},#{sex},#{idNumber},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void addEmployee(Employee employee);

    @Select("select * from employee where id = #{id}")
    Employee getById(Long id);

//    @Update("update employee set name = #{name},username = #{username},phone = #{phone},sex = #{sex},id_number = #{idNumber},status = #{status},update_time = #{updateTime},update_user = #{updateUser} where id = #{id}")
    void updateEmployee(Employee employee);
}
